package com.example.demo.mapper;

import com.example.demo.model.NewsInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NewsInfoMapper {
    @Select("SELECT *from news_list where `status_code`!=0 AND id= #{id}")
    NewsInfo queryNewsInfoById(Integer id);

    @Select("SELECT *from news_list where `status_code`!=0 ")
    List<NewsInfo> getNewsList();


    @Insert("insert into news_list (`title`,`author`,`news_date`,`heat`,`news_content`)"+
    "values (#{title},#{author},#{newsDate},#{heat},#{newsContent})")
    Integer addNews(NewsInfo newsInfo);

    Integer updateNews(NewsInfo newsInfo);
    Integer batchDelete(List<Integer> ids);

    @Select("SELECT `title` ,`news_content` from news_list where `status_code`!=0 AND id= #{id}")
    NewsInfo getNewsText(Integer id);
}
